package com.proxy.scanandcheck.common.valueobject;

import java.io.Serializable;
import java.util.Date;

import org.jsoup.nodes.Document;

import com.proxy.scanandcheck.common.util.Constants;


/**
 * Proxy value object
 *
 */
public class Proxy implements Serializable{
	
	private static final long serialVersionUID = -619701808597574834L;
	
	private String hostname = "";
	private int port = Constants.PORT_80;
	private String schemeName = Constants.HTTP_SCHEME;
	private String proxy;
	private boolean validForGoogleHost = false;
	private boolean validForOtherHost = false;
	private Date updateTimeForGoogleHost;
	private Date updateTimeForOtherHost;
	private String ipClass;
	
	private Document document = null;
	
	public String getHostname() {
		return hostname;
	}
	public void setHostname(String hostname) {
		this.hostname = hostname;
	}
	public int getPort() {
		return port;
	}
	public void setPort(int port) {
		this.port = port;
	}
	public String getSchemeName() {
		return schemeName;
	}
	public void setSchemeName(String schemeName) {
		this.schemeName = schemeName;
	}
	public String getProxy() {
		return proxy;
	}
	public void setProxy(String proxy) {
		this.proxy = proxy;
		try {
			String [] splitProxy = this.proxy.split(":");
			this.hostname = splitProxy[0];
			this.port = Integer.valueOf(splitProxy[1]);
			this.schemeName = "http";
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
	}
	public boolean isValidForGoogleHost() {
//		return true;
		return validForGoogleHost;
	}
	public void setValidForGoogleHost(boolean validForGoogleHost) {
		this.validForGoogleHost = validForGoogleHost;
	}
	public boolean isValidForOtherHost() {
		return validForOtherHost;
	}
	public void setValidForOtherHost(boolean validForOtherHost) {
		this.validForOtherHost = validForOtherHost;
	}
	public Date getUpdateTimeForGoogleHost() {
		return updateTimeForGoogleHost;
	}
	public void setUpdateTimeForGoogleHost(Date updateTimeForGoogleHost) {
		this.updateTimeForGoogleHost = updateTimeForGoogleHost;
	}
	public Date getUpdateTimeForOtherHost() {
		return updateTimeForOtherHost;
	}
	public void setUpdateTimeForOtherHost(Date updateTimeForOtherHost) {
		this.updateTimeForOtherHost = updateTimeForOtherHost;
	}
	public Document getDocument() {
		return document;
	}
	public void setDocument(Document document) {
		this.document = document;
	}
	public String getIpClass() {
		return ipClass;
	}
	public void setIpClass(String ipClass) {
		this.ipClass = ipClass;
	}
	
	public String toString() {
		return proxy + " result - " + validForGoogleHost;
	}

}
